package com.button.boot.redis.lettuce.service.impl;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import com.button.boot.redis.lettuce.model.UserModel;
import com.button.boot.redis.lettuce.service.RedisManager;

@Service
public class RedisManagerImpl implements RedisManager {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Resource   //此处使用@Autowired会注入异常(https://blog.csdn.net/zhaoheng314/article/details/81564166)
    private RedisTemplate<String, UserModel> redisTemplate;

    @Override
    public void setValue(String key, String value) {
        
        stringRedisTemplate.opsForValue().set(key, value);
    }
    @Override
    public String getValue(String key) {
        return stringRedisTemplate.opsForValue().get(key);
    }
    @Override
    public void leftPush(String key, UserModel value) {
        redisTemplate.opsForList().leftPush(key, value);
    }
    @Override
    public UserModel leftPop(String key) {
        return redisTemplate.opsForList().leftPop(key);
    }
}
